home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2008 January / Mac_easy_01_08.iso / Software / Online / Chat / macam.0.9.1.dmg / macam source / utilities / yuv2rgb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2006-03-03  |  5.7 KB  |  129 lines

  1. /*
  2.     macam - webcam app and QuickTime driver component
  3.     Copyright (C) 2002 Matthias Krauss (macam@matthias-krauss.de)
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  $Id: yuv2rgb.c,v 1.3 2006/03/03 15:33:21 hxr Exp $
  19. */
  20.  
  21. #include "yuv2rgb.h"
  22. #include <stdio.h>
  23. #include <CoreFoundation/CFByteOrder.h>
  24.  
  25. //Lazy preprocessor generation of blitter code. For documentation, see "yuv2rgbPhilips.c".
  26.  
  27. #undef YUV2RGB_CPIA420STYLE
  28. #undef YUV2RGB_FLIP
  29. #undef YUV2RGB_ALPHA
  30. void _philips2rgb888      (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  31. #include "yuv2rgbPhilips.c"
  32. }
  33. void _cpia4202rgb888      (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  34. #include "yuv2rgbCPIA420.c"
  35. }
  36. void _cpia4222rgb888      (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  37. #include "yuv2rgbCPIA422.c"
  38. }
  39. void _ov4202rgb888      (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  40. #include "yuv2rgbOV420.c"
  41. }
  42.     
  43. #undef YUV2RGB_FLIP
  44. #define YUV2RGB_ALPHA
  45. void _philips2argb8888    (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  46. #include "yuv2rgbPhilips.c"
  47. }
  48. void _cpia4202argb8888    (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  49. #include "yuv2rgbCPIA420.c"
  50. }
  51. void _cpia4222argb8888    (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  52. #include "yuv2rgbCPIA422.c"
  53. }
  54. void _ov4202argb8888    (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  55. #include "yuv2rgbOV420.c"
  56. }
  57.     
  58. #define YUV2RGB_FLIP
  59. #undef YUV2RGB_ALPHA
  60. void _philips2rgb888flip  (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  61. #include "yuv2rgbPhilips.c"
  62. }
  63. void _cpia4202rgb888flip  (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  64. #include "yuv2rgbCPIA420.c"
  65. }
  66. void _cpia4222rgb888flip  (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  67. #include "yuv2rgbCPIA422.c"
  68. }
  69.  
  70. void _ov4202rgb888flip  (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  71. #include "yuv2rgbOV420.c"
  72. }
  73.     
  74. #define YUV2RGB_FLIP
  75. #define YUV2RGB_ALPHA
  76. void _philips2argb8888flip(int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  77. #include "yuv2rgbPhilips.c"
  78. }
  79. void _cpia4202argb8888flip(int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  80. #include "yuv2rgbCPIA420.c"
  81. }
  82. void _cpia4222argb8888flip(int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  83. #include "yuv2rgbCPIA422.c"
  84. }
  85.  
  86. void _ov4202argb8888flip(int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  87. #include "yuv2rgbOV420.c"
  88. }
  89.  
  90. #undef YUV2RGB_FLIP
  91. #undef YUV2RGB_ALPHA
  92.  
  93. void yuv2rgb(int width,
  94.              int height,
  95.              YUVStyle style,
  96.              unsigned char *src,
  97.              unsigned char *dst,
  98.              short bpp,
  99.              long srcRowExtra,
  100.              long dstRowExtra,
  101.              bool flip) {
  102.  
  103.     long decide=4*((unsigned long)style)+((bpp==4)?2:0)+((flip)?1:0);
  104.     //Bit 0=flip, bit 1=alpha, bit 2...=cpiaStyle
  105.     switch (decide) {
  106.         case  0: _philips2rgb888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  107.         case  1: _philips2rgb888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  108.         case  2: _philips2argb8888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  109.         case  3: _philips2argb8888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  110.         case  4: _cpia4202rgb888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  111.         case  5: _cpia4202rgb888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  112.         case  6: _cpia4202argb8888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  113.         case  7: _cpia4202argb8888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  114.         case  8: _cpia4222rgb888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  115.         case  9: _cpia4222rgb888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  116.         case 10: _cpia4222argb8888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  117.         case 11: _cpia4222argb8888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  118.         case 12: _ov4202rgb888            (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  119.         case 13: _ov4202rgb888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  120.         case 14: _ov4202argb8888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  121.         case 15: _ov4202argb8888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  122.         default:
  123. #ifdef _VERBOSE_
  124.         printf("yuv2rgb: unknown conversion\n");
  125. #endif
  126.             break;
  127.     }
  128. }
  129.